﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RelationExpertSystem.Relation
{
    public class Grandson : RelationBase
    {
        private static Grandson _singleton = new Grandson();
        public static Grandson Instance
        {
            get { return _singleton; }
        }

        private Grandson() { }

        public override bool IsRelated(Person a, Person b)
        {
            // b is a's Grandson IFF b is male AND b is a's grandchild
            return b.Sex == Sex.Male && a.KnownRelation(Grandchild.Instance, b);
        }

        public override IEnumerable<IRelation> GetDependencies()
        {
            return new HashSet<IRelation>(new IRelation[] { Grandchild.Instance });
        }
    }
}
